import json
from src.common.logger import getLogger
from flask import Blueprint, Response, request
from src.modules.home.service import HomeService

logger = getLogger()
api = Blueprint('home', __name__)

@api.route('/home/current_new')
def snatch_current_new():
    results = HomeService.snatch_current_new()
    return Response(json.dumps({ "code": 200, "data": results }), status = 200, mimetype = 'application/json')

@api.route('/home/current_weather')
def snatch_current_weather():
    results = HomeService.snatch_current_weather(request.args)
    return Response(json.dumps({ "code": 200, "data": results }), status = 200, mimetype = 'application/json')

@api.route('/home/refresh_statistics')
def snatch_refresh_statistics():
    results = HomeService.snatch_refresh_statistics(request.args)
    return Response(json.dumps({ "code": 200, "data": results }), status = 200, mimetype = 'application/json')
